combobox: Stop using old styling code
authorBenjamin Otte <otte@redhat.com>
Sat, 12 Sep 2015 23:52:49 +0000 (01:52 +0200)
committerBenjamin Otte <otte@redhat.com>
Sat, 12 Sep 2015 23:54:03 +0000 (01:54 +0200)
Instead of get_path_for_child() use CSS nodes.

gtk/gtkcombobox.c

index 4d2d82511467ea92f96420b12cd55c18fc02706a..c9962badcec9b2ce7401aa3f126444d3cc1f9d92 100644 (file)
@@ -26,6 +26,7 @@
 #include "gtkcelllayout.h"
 #include "gtkcellrenderertext.h"
 #include "gtkcellview.h"
+#include "gtkcssnodeprivate.h"
 #include "gtkeventbox.h"
 #include "gtkframe.h"
 #include "gtkbox.h"
@@ -453,8 +454,6 @@ static void     gtk_combo_box_get_preferred_height_for_width (GtkWidget    *widg
                                                               gint          avail_size,
                                                               gint         *minimum_size,
                                                               gint         *natural_size);
-static GtkWidgetPath *gtk_combo_box_get_path_for_child       (GtkContainer *container,
-                                                              GtkWidget    *child);
 static void     gtk_combo_box_direction_changed              (GtkWidget    *widget,
                                                               GtkTextDirection  previous_direction);
 
@@ -481,7 +480,6 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
   container_class->forall = gtk_combo_box_forall;
   container_class->add = gtk_combo_box_add;
   container_class->remove = gtk_combo_box_remove;
-  container_class->get_path_for_child = gtk_combo_box_get_path_for_child;
 
   gtk_container_class_handle_border_width (container_class);
 
@@ -1362,89 +1360,11 @@ gtk_combo_box_button_state_flags_changed (GtkWidget     *widget,
   gtk_widget_queue_draw (widget);
 }
 
-static void
-gtk_combo_box_invalidate_order_foreach (GtkWidget *widget)
-{
-  _gtk_widget_invalidate_style_context (widget, GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION);
-}
-
-static void
-gtk_combo_box_invalidate_order (GtkComboBox *combo_box)
-{
-  gtk_container_forall (GTK_CONTAINER (combo_box),
-                        (GtkCallback) gtk_combo_box_invalidate_order_foreach,
-                        NULL);
-}
-
 static void
 gtk_combo_box_direction_changed (GtkWidget        *widget,
                                  GtkTextDirection  previous_direction)
 {
-  gtk_combo_box_invalidate_order (GTK_COMBO_BOX (widget));
-}
-
-static GtkWidgetPath *
-gtk_combo_box_get_path_for_child (GtkContainer *container,
-                                  GtkWidget    *child)
-{
-  GtkComboBoxPrivate *priv = GTK_COMBO_BOX (container)->priv;
-  GtkWidgetPath *path;
-  GtkWidget *widget;
-  gboolean found = FALSE;
-  GList *visible_children, *l;
-  GtkWidgetPath *sibling_path;
-  int pos;
-
-  path = _gtk_widget_create_path (GTK_WIDGET (container));
-
-  if (gtk_widget_get_visible (child))
-    {
-      visible_children = NULL;
-
-      if (priv->button && gtk_widget_get_visible (priv->button))
-        visible_children = g_list_prepend (visible_children, priv->button);
-
-      widget = gtk_bin_get_child (GTK_BIN (container));
-      if (widget && gtk_widget_get_visible (widget))
-        visible_children = g_list_prepend (visible_children, widget);
-
-      if (gtk_widget_get_direction (GTK_WIDGET (container)) == GTK_TEXT_DIR_RTL)
-        visible_children = g_list_reverse (visible_children);
-
-      pos = 0;
-
-      for (l = visible_children; l; l = l->next)
-        {
-          widget = l->data;
-
-          if (widget == child)
-            {
-              found = TRUE;
-              break;
-            }
-
-          pos++;
-        }
-    }
-
-  if (found)
-    {
-      sibling_path = gtk_widget_path_new ();
-
-      for (l = visible_children; l; l = l->next)
-        gtk_widget_path_append_for_widget (sibling_path, l->data);
-
-      gtk_widget_path_append_with_siblings (path, sibling_path, pos);
-
-      g_list_free (visible_children);
-      gtk_widget_path_unref (sibling_path);
-    }
-  else
-    {
-      gtk_widget_path_append_for_widget (path, child);
-    }
-
-  return path;
+  gtk_css_node_reverse_children (gtk_widget_get_css_node (widget));
 }
 
 static void
@@ -1561,6 +1481,11 @@ gtk_combo_box_add (GtkContainer *container,
     }
   
   gtk_widget_set_parent (widget, GTK_WIDGET (container));
+  if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR)
+    gtk_css_node_insert_after (gtk_widget_get_css_node (GTK_WIDGET (combo_box)),
+                               gtk_widget_get_css_node (widget),
+                               NULL);
+
   _gtk_bin_set_child (GTK_BIN (container), widget);
 
   if (priv->has_entry)